import { Controller, Post, Body, Get, Query, Param } from '@nestjs/common';
import { MemoryService } from './memory.service';

@Controller('memory')
export class MemoryController {
  constructor(private readonly memoryService: MemoryService) {}

  //上传内存信息
  @Post('/info')
  createMemoryInfo(@Body() body: any) {
    console.log(body);

    return this.memoryService.createMemoryInfo(body);
  }

  //获取内存信息
  @Get('/info')
  getMemoryInfo(@Query() query: any) {
    return this.memoryService.getMemoryInfo(query);
  }

  //获取内存信息
  @Get('/info/:id')
  getMemoryInfoById(@Param('id') id: string) {
    return this.memoryService.getMemoryInfoById(id);
  }

  //更新内存信息
  @Post('/info/:id')
  updateMemoryInfo(@Param('id') id: string, @Body() body: any) {
    return this.memoryService.updateMemoryInfo(id, body);
  }

  //删除内存信息
  @Post('/info/delete/:id')
  deleteMemoryInfo(@Param('id') id: string) {
    return this.memoryService.deleteMemoryInfo(id);
  }

  //请求所有内存信息
  @Get('/total')
  getTotal() {
    return this.memoryService.getAllMemoryInfo();
  }
}
